CFLAGS := -g -O0 -Wall  # 添加调试信息并禁用优化

log:=thirdparty/log.c thirdparty/log.h
json:=thirdparty/cJSON.c thirdparty/cJSON.h

common:=app/app_common.c app/app_common.h

message:=app/app_message.c app/app_message.h

mqtt:=app/app_mqtt.c app/app_mqtt.h

pool:=app/app_pool.c app/app_pool.h

buffer:=app/app_buffer.c app/app_buffer.h

dev:=app/app_device.c app/app_device.h

bt:= app/app_bt.c app/app_bt.h

test_log: test/test_log.c $(log)
	gcc $(CFLAGS) -o $@ $^ -Ithirdparty
	./$@
	rm -f $@

test_json: test/test_json.c $(json)
	gcc $(CFLAGS) -o $@ $^ -Ithirdparty
	./$@
	rm -f $@

test_common: test/test_common.c $(common)
	gcc $(CFLAGS) -o $@ $^ -Iapp
	./$@
	rm -f $@

test_message: test/test_message.c $(message) $(log) $(json) $(common) 
	gcc $(CFLAGS) -o $@ $^ -Iapp -Ithirdparty
	./$@
	rm -f $@

test_mqtt: test/test_mqtt.c $(mqtt) $(log) 
	gcc $(CFLAGS) -o $@ $^ -Iapp -Ithirdparty -lpaho-mqtt3c
	./$@
	rm -f $@

test_pool: test/test_pool.c $(pool) $(log) 
	gcc $(CFLAGS) -o $@ $^ -Iapp -Ithirdparty
	./$@
	rm -f $@

test_buffer: test/test_buffer.c $(buffer) $(log)
	gcc $(CFLAGS) -o $@ $^ -Iapp -Ithirdparty
	./$@
	rm -f $@

test_dev:test/test_dev.c $(bt) $(dev) $(log) $(json) $(common) $(message) $(mqtt) $(pool) $(buffer)
	gcc $(CFLAGS) -o $@ $^ -Iapp -Ithirdparty -lpaho-mqtt3c
	./$@
	rm -f $@